package com.buba.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GateWayConfig {
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();

        //全局food列表路由：http://localhost:9527/backstagesupporter/food/getAllFood
        routes.route("route-path1", r -> r.path("/backstagesupporter/food/getAllFood").uri("http://localhost:8002/food/getAllFood")).build();

        //前台登录路由：http://localhost:9527/frontdesk/login
        routes.route("route-path2", r -> r.path("/frontdesk/login").uri("http://localhost:8003/frontdesk/login")).build();

        //获取验证码路由：http://localhost:9527/frontdesk/createCode/{phone}
        routes.route("route-path3", r -> r.path("/frontdesk/createCode/{phone}").uri("http://localhost:8003/frontdesk/createCode/*")).build();

        //校验验证码路由：http://localhost:9527/frontdesk/check
        routes.route("route-path4", r -> r.path("/frontdesk/check").uri("http://localhost:8003/frontdesk/check")).build();

        //添加food路由：http://localhost:9527/backstagesupporter/food/saveFood
        routes.route("route-path5", r -> r.path("/backstagesupporter/food/saveFood").uri("http://localhost:8002/food/saveFood")).build();

        //删除food路由：http://localhost:9527/backstagesupporter/food/deleteFoodById
        routes.route("route-path6", r -> r.path("/backstagesupporter/food/deleteFoodById").uri("http://localhost:8002/food/deleteFoodById")).build();

        //修改food路由：http://localhost:9527/backstagesupporter/food/updateFood
        routes.route("route-path7", r -> r.path("/backstagesupporter/food/updateFood").uri("http://localhost:8002/food/updateFood")).build();

        //上下架food路由：http://localhost:9527/backstagesupporter/food/updateFoodStatus
        routes.route("route-path8", r -> r.path("/backstagesupporter/food/updateFoodStatus").uri("http://localhost:8002/food/updateFoodStatus")).build();

        //订单查询路由：http://localhost:9527/backstagesupporter/orde/getAllOrders
        routes.route("route-path9", r -> r.path("/backstagesupporter/orde/getAllOrders").uri("http://localhost:8004/backstagesupporter/orde/getAllOrders")).build();

        //图片上传路由：http://localhost:9527/backstagesupporter/food/upload
        routes.route("route-path10", r -> r.path("/backstagesupporter/food/upload").uri("http://localhost:8002/food/upload")).build();

        //注销路由：http://localhost:9527/frontdesk/signOut
        routes.route("route-path11", r -> r.path("/frontdesk/signOut").uri("http://localhost:8003/frontdesk/signOut")).build();

        //修改用户个人信息路由：http://localhost:9527/user/updateUser
        routes.route("route-path12", r -> r.path("/user/updateUser").uri("http://localhost:8005/user/updateUser")).build();

        //修改用户头像信息路由：http://localhost:9527/user/upload
        routes.route("route-path13", r -> r.path("/user/upload").uri("http://localhost:8005/user/upload")).build();

        //查看个人订单路由：http://localhost:9527/frontdesk/order/getOrderByUserId
        routes.route("route-path14", r -> r.path("/frontdesk/order/getOrderByUserId").uri("http://localhost:80/frontdesk/order/getOrderByUserId")).build();

        //后台登录路由：http://localhost:9527/backstagesupporter/main/login
        routes.route("route-path15", r -> r.path("/backstagesupporter/main/login").uri("http://localhost:8006/backstagesupporter/main/login")).build();

        //后台员工查询路由：http://localhost:9527/backstagesupporter/main/hfstaff
        routes.route("route-path16", r -> r.path("/backstagesupporter/main/hfstaff").uri("http://localhost:8013/backstagesupporter/main/hfstaff")).build();

        //后台菜品类型路由：http://localhost:9527/backstagesupporter/getFoodType
        routes.route("route-path17", r -> r.path("/backstagesupporter/getFoodType").uri("http://localhost:8009/backstagesupporter/getFoodType")).build();

        //后台优惠券列表全查路由：http://localhost:9527/backstagesupporter/coupon/getAllCoupon
        routes.route("route-path18", r -> r.path("/backstagesupporter/coupon/getAllCoupon").uri("http://localhost:8015/backstagesupporter/coupon/getAllCoupon")).build();

        //订单信息查看路由：http://localhost:9527/frontdesk/order/findOrderFoods
        routes.route("route-path19", r -> r.path("/frontdesk/order/findOrderFoods").uri("http://localhost:80/frontdesk/order/findOrderFoods")).build();

        //后台优惠券领取记录全查路由：http://localhost:9527/backstagesupporter/coupon/getAllReceiveRecordByCoupon
        routes.route("route-path20", r -> r.path("/backstagesupporter/coupon/getAllReceiveRecordByCoupon").uri("http://localhost:8015/backstagesupporter/coupon/getAllReceiveRecordByCoupon")).build();

        //后台优惠券使用记录全查路由：http://localhost:9527/backstagesupporter/coupon/getAllUseRecordByCoupon
        routes.route("route-path21", r -> r.path("/backstagesupporter/coupon/getAllUseRecordByCoupon").uri("http://localhost:8015/backstagesupporter/coupon/getAllUseRecordByCoupon")).build();

        //后台创建优惠券路由：http://localhost:9527/backstagesupporter/coupon/saveCoupon
        routes.route("route-path22", r -> r.path("/backstagesupporter/coupon/saveCoupon").uri("http://localhost:8015/backstagesupporter/coupon/saveCoupon")).build();

        //后台注册路由: http://localhost:9527/backstagesupporter/main/addHfregister
        routes.route("route-path23", r -> r.path("/backstagesupporter/main/addHfregister").uri("http://localhost:8013/backstagesupporter/main/addHfregister")).build();

        //后台注册申请查看路由: http://localhost:9527/backstagesupporter/main/hfregister
        routes.route("route-path24", r -> r.path("/backstagesupporter/main/hfregister").uri("http://localhost:8013/backstagesupporter/main/hfregister")).build();

        //后台拒绝申请路由: http://localhost:9527/backstagesupporter/main/updRegister
        routes.route("route-path25", r -> r.path("/backstagesupporter/main/updRegister").uri("http://localhost:8013/backstagesupporter/main/updRegister")).build();

        //后台同意申请路由: http://localhost:9527/backstagesupporter/main/hfRegister
        routes.route("route-path26", r -> r.path("/backstagesupporter/main/hfRegister").uri("http://localhost:8013/backstagesupporter/main/hfRegister")).build();

        //后台优惠券开关路由：http://localhost:9527/backstagesupporter/coupon/alterSwitch
        routes.route("route-path27", r -> r.path("/backstagesupporter/coupon/alterSwitch").uri("http://localhost:8015/backstagesupporter/coupon/alterSwitch")).build();

        //后台修改优惠券路由：http://localhost:9527/backstagesupporter/coupon/updateCoupon
        routes.route("route-path28", r -> r.path("/backstagesupporter/coupon/updateCoupon").uri("http://localhost:8015/backstagesupporter/coupon/updateCoupon")).build();

        //前台查询优惠券以及优惠卷单查路由：http://localhost:9527/frontdesk/discount/finddiscount
        routes.route("route-path29", r -> r.path("/frontdesk/discount/finddiscount").uri("http://localhost:8016//frontdesk/discount/finddiscount")).build();

        //后台删除菜品类型路由：http://localhost:9527/backstagesupporter/deleteFoodTypeById
        routes.route("route-path30", r -> r.path("/backstagesupporter/deleteFoodTypeById").uri("http://localhost:8009/backstagesupporter/deleteFoodTypeById")).build();

        //领取优惠券路由：http://localhost:9527/frontdesk/discount/GetCoupon
        routes.route("route-path31", r -> r.path("/frontdesk/discount/GetCoupon").uri("http://localhost:8016/frontdesk/discount/GetCoupon")).build();

        //查询用户优惠券路由：http://localhost:9527/frontdesk/discount/findCouponByUid
        routes.route("route-path32", r -> r.path("/frontdesk/discount/findCouponByUid").uri("http://localhost:8016/frontdesk/discount/findCouponByUid")).build();

        return routes.build();

    }
}
